#include "src/Client.h"
#include <iostream>

bool onMessage(int _conv, char* _key, std::string _payload, char* _res_key, char* _response) {
	std::cout << _conv << ": " << _payload << std::endl;

	delete _key;
	return false;
}
bool onConnected(unsigned int conv) {
	std::cout << conv << " onConnected" << std::endl;
	return false;
}
bool onClosed(unsigned int conv) {
	std::cout << conv << " onClosed" << std::endl;
	return false;
}

int main() {
	Client* client = new Client(nullptr, 30);
	client->setOnMessageCallbackFunction(std::bind(onMessage, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
	client->setOnConnectedCallbackFunction(std::bind(onConnected, std::placeholders::_1));
	client->setOnClosedCallbackFunction(std::bind(onClosed, std::placeholders::_1));
	client->start();
	// client->connect(9001, "127.0.0.1", 9001, true);
	std::string message = "";
	bool stop = false;
	while (!stop) {
		std::cin >> message;
		stop = message.compare("exit") == 0;
		if (stop) {
			break;
		}
		client->sendMessage(9001, "message", message);
	}
	

	delete client;
	return 0;
}
